import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
// import type{ILogininfo} from '@/types/login/Iys'
import {userhqInfo} from '@/api/UserInformation/userInfo'
const GSJ_TOKEN='GSJ_TOKEN'
const GSJ_UID='GSJ_UID'
const GSJ_INFO='GSJ_INFO'
const GSJ_permission='GSJ_permission'
const GSJ_menu='GSJ_menu'

type ILogininfo={
  token:string,
  tokenExpired:string
}
export const usestore = defineStore('user',{
      
  state:()=>({
    token:'',
    tokenExpired:'',
    uid:'',
    userInfo:{
      avatar: '',
      nickname: ''
    },
    permission:[],
    role:[]
  }),
  actions:{
    ff(){
      userhqInfo().then((res:any)=>{
        console.log(res)
        let {uid,userInfo,permission,role} = res
       this. uid=uid
       this. userInfo=userInfo
       this. permission=permission
       this. role=role
      })
    },
    usertoken(val:ILogininfo){
        let {token,tokenExpired}=val
        console.log(val)
      this. token=token
       this.tokenExpired=tokenExpired
      
    },


    // [GSJ_TOKEN](val:string){
    //   console.log(val)
    //    this.token=val
    // },
    // [GSJ_UID](val:string){
    //   console.log(val)

    //   this.uid=val
    // },
    // [GSJ_INFO](val:any){
    //   console.log(val)

    //   this.userInfo=val
    // },
    // [GSJ_permission](val:any){
    //   console.log(val)
    //      this.permission=val
    // },
    // [GSJ_menu](val:any){
    //   this.menu=val
    // }
  }
 
})
